package com.icangya.service.impl;


import com.icangya.DAO.IBadUserDAO;
import com.icangya.domain.BadUserDO;
import com.icangya.service.IBadUserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.sql.Timestamp;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.List;

@Service("BadUserServiceImpl")
public class BadUserServiceImpl implements IBadUserService{

    @Autowired
    private IBadUserDAO iBadUserDAO;

    @Override
    public void addBadUser(String openId, String reson){
        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-mm-dd HH:mm:ss");
        BadUserDO badUserDO = new BadUserDO();
        badUserDO.setOpenId(openId);
        badUserDO.setReson(reson);
        badUserDO.setCreateTime(new Timestamp(new Date().getTime()));
        iBadUserDAO.save(badUserDO);
    }

    @Override
    public List<BadUserDO> getBadUserByOpenid(String openId) {
        List<BadUserDO> badUserDOList =  iBadUserDAO.getBadUserByOpenid(openId);
        return badUserDOList;
    }
}
